package tagcloud.core;

public class Word implements Comparable<Word> {

	private String text;
	private int numOccurences;
	
	public Word(String text) {
		this(text, 0);
	}
	
	public Word(String text, int numOccurences) {
		this.text = text;
		this.numOccurences = numOccurences;
	}
	
	public String getText() {
		return text;
	}
	
	public int getNumOccurences() {
		return numOccurences;
	}
	
	public void setNumOccurences(int newNumOccurences) {
		numOccurences = newNumOccurences;
	}
	
	public int compareTo(Word other) {
		if(numOccurences != other.numOccurences) {
			return other.numOccurences - numOccurences;
		} else {
			return text.compareTo(other.text);
		}
	}
	
	public String toString() {
		return text;
	}
	
}
